<style> .errors{color:red;}</style>
<script>
    function clearForm() {
        $form = document.bibliotecario;
        alert($form);
    }
    
    function aceptDelet(url) {
        var answer = confirm ("Se eliminara el bibliotecario, esta seguro?");
        if (answer) {
            window.location = url;
            //alert(url);
        }
    }
</script>
<div class="gb-layout-wrapper">
    <div class="gb-content-layout">
        <div class="gb-content-layout-row">
            <div class="gb-layout-cell gb-sidebar1">

                <!-- navbar2 start here-->
                <?php include(APPLICATION_PATH . "/modules/default/views/scripts/index/navbar2_administracion.phtml"); ?>
                <!-- navbar2 finish here-->

                <div class="cleared"></div>
            </div>
            
            <!-- content start here-->
            <div class="gb-layout-cell gb-content">
                
                <!-- -->
                <div class="gb-box gb-post">
                    <div class="gb-box-body gb-post-body">
                        <div class="gb-post-inner gb-article">
                            <h2 class="gb-postheader"><a href="Blog Posts/post.html">Bibliotecarios</a></h2>
                            <form name="bibliotecario" id="bibliotecario" method="post" action="">
                                <fieldset>
                                    <label for="name">Nombre</label><br />
                                    <?php echo $this->form->name;?>
                                    <div>
                                        <br />
                                    </div>
                                    <div style="width: 190px; float: left;">
                                        <label for="logname">Usuario</label><br />
                                        <?php echo $this->form->logname;?>
                                    </div>
                                    <div>
                                        <label for="passwd">contraseña</label><br />
                                        <?php echo $this->form->passwd;?>
                                    </div>
                                    <div>
                                        <br />
                                    </div>
                                    <div style="width: 190px; float: left;">
                                        <label for="roleId">Rol</label><br />
                                        <select name="roleId">
                                        <?php if ($this->form->hiddenedit->getValue() != "none" ) { $rol_id = $this->form->hiddenedit->getValue(); } else { $rol_id = '';}?>
                                        <?php foreach ($this->list_roles as $rol) {?>
                                            <option value="<?php echo $rol->id; ?>" <?php if ($rol->id == $rol_id) {echo "SELECTED ";}?> ><?php echo $rol->nombre; ?></option>
                                        <?php }?>
                                        </select>
                                    </div>
                                    <div>
                                        <br />
                                        <?php echo $this->form->chkbloqueado;?>
                                        <label for="chkbloqueado">Bloqueado</label>
                                    </div>
                                    <div>
                                        <br />
                                    </div>
                                    <?php if ($this->form->hiddenedit->getValue() != "none" ) { echo $this->form->hiddenedit; }?>
                                    <div style="float: left;padding-left: 15px;padding-top: 10px;">
                                        <?php 
                                          $getParam = Zend_Controller_Front::getInstance()->getRequest()->getParams();
                                          if (isset($getParam['msg'])) {
                                              switch ($getParam['msg']) {
                                                    case "a1":
                                                        echo "<span style='color:blue;'>El bibliotecario se guardo correctamente.</span>";
                                                        break;
                                                    case "a2":
                                                        echo "<span class='errors'>No se pudo guardar el bibliotecario, nombre de usuario duplicado.</span>";
                                                        break;
                                                    case "b1":
                                                        echo "<span style='color:blue;'>El bibliotecario se modifico correctamente.</span>";
                                                        break;
                                                    case "b2":
                                                        echo "<span class='errors'>No se pudo modificar el bibliotecario, nombre duplicado.</span>";
                                                        break;
                                                    case "c1":
                                                        echo "<span style='color:blue;'>El bibliotecario se ha eliminado.</span>";
                                                        break;
                                                    case "c2":
                                                        echo "<span class='errors'>No se pudo eliminar el bibliotecario, nombre de usuario duplicado.</span>";
                                                        break;
                                                }
                                          }
                                        ?>
                                    </div>
                                    <div style="width: auto; float: right;">
                                        <?php if ($this->form->hiddenedit->getValue() != "none" ) { echo $this->form->BtnCancel; }?>
                                        <?php echo $this->form->BtnGuardar; ?>
                                    </div><div class="cleared"></div>
                                </fieldset>
                            </form>
                            <br />
                            <form name="search" id="search" method="post" action="">
                                <fieldset>
                                    <div style="text-align: center;">
                                        <label for="searchword">Nombre</label>
                                        <?php echo $this->search->searchword;?>
                                        <?php echo $this->search->BtnSearch; ?>
                                    </div>
                                </fieldset>
                            </form>
                            <div>
                                <br />
                            </div>

                            <div class="cleared"></div>
                            <div class="gb-postcontent">
                                <table class="" style="border-collapse: separate;margin: 0;" cellspacing="0" width="100%">
                                    <thead class="gb-postmetadatafooter" style="border:1px solid #A3BDA5;padding: 1px;position: relative;z-index: 1;">
                                        <th>Nro</th>
                                        <th>Nombre</th>
                                        <th>Login</th>
                                        <th>Rol</th>
                                        <th>Bloqueado</th>
                                        <th>&nbsp;</th>
                                        <th>&nbsp;</th>
                                    </thead>
                                    <tbody>
                                        <?php $i = 1?>
                                        <?php foreach ($this->bibliotecarios as $bibliotecario) {?>
                                        <tr>
                                            <td><?php echo $i;?></td>
                                            <td><?php echo $bibliotecario->nombre;?></td>
                                            <td><?php echo $bibliotecario->login;?></td>
                                            <td><?php echo Rol::GetInstancia($bibliotecario->rol_id)->nombre;?></td>
                                            <td style="text-align:center;"><?php if ($bibliotecario->bloqueado == "1") {echo "Si";}else{echo "No";}?></td>
                                            <td>
                                                <?php
                                                if ($bibliotecario->id != 1 || $bibliotecario->id == Zend_Auth::getInstance()->getIdentity()->bibliotecario_id) {?>
                                                    <a href="<?php echo $this->myUrl(array(), 'home'); ?>administracion/bibliotecarios/edit/<?php echo $bibliotecario->id;?>">Editar</a>
                                                <?php } else {?>
                                                    &nbsp;
                                                <?php }?>
                                            </td>
                                            <td>
                                                <?php if ($bibliotecario->id != 1 && $bibliotecario->id != Zend_Auth::getInstance()->getIdentity()->bibliotecario_id) {?>
                                                    <a href="javascript:aceptDelet('<?php echo $this->myUrl(array(), 'home'); ?>administracion/bibliotecarios/delet/<?php echo $bibliotecario->id;?>');">Borrar</a>
                                                    <!--<a href="<?php //echo $this->myUrl(array(), 'home'); ?>administracion/bibliotecarios/delet/<?php //echo $bibliotecario->id;?>">Borrar</a>-->
                                                <?php } else {?>
                                                    &nbsp;
                                                <?php }?>
                                            </td>
                                        </tr>
                                        <?php $i++;?>
                                        <?php }?>
                                    </tbody>
                                </table>
                            </div>
                            

                        </div>
                        <div class="cleared"></div>
                    </div>
                </div>
                <!-- -->
                
                <div class="cleared"></div>
            </div>
            <!-- content finish here-->
        </div>
    </div>
</div>